package com.nchu.ft.controller;


import com.nchu.ft.common.domain.ApiResult;
import com.nchu.ft.entity.Couple;
import com.nchu.ft.service.CoupleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @ClassName: CoupleController
 * @description:
 * @Author: Chuanwei Li
 * @CreateTime: 2025-08-17 15:53
 * @Version: 1.0
 */
@RestController
@RequestMapping("/couple")
public class CoupleController {

    @Autowired
    private CoupleService<Couple> coupleService;

    @PostMapping("/addCouple")
    public ApiResult<Boolean> addCouple(Couple couple) {
        return ApiResult.success(coupleService.save(couple));
    }

    @PostMapping("/updateCouple")
    public ApiResult<Boolean> updateCouple(Couple couple) {
        return ApiResult.success(coupleService.updateById(couple));
    }

    @PostMapping("/deleteCouple")
    public ApiResult<Boolean> deleteCouple(Integer id) {
        return ApiResult.success(coupleService.removeById(id));
    }

    @GetMapping("/getCoupleById")
    public ApiResult<Couple> getCouple(@RequestParam("coupleId") Integer coupleId) {
        return ApiResult.success(coupleService.getById(coupleId));
    }

    @GetMapping("/getCoupleList")
    public ApiResult<List<Couple>> getCoupleList() {
        return ApiResult.success(coupleService.list());
    }
}
